﻿#region Using Directives

    using System;

using MarketPulse.BusinessLogic.Common;

#endregion

namespace MarketPulse.BusinessLogic.Private.StateMachine
{
    internal class AssignmentStateFactory
    {
        public static IAssignmentState Create(Guid visitStatusTypeGuid, bool throwIfInvalid)
        {
            if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.Assigned) == 0)
            {
                return new AssignmentStateAssigned(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.AwaitingQA) == 0)
            {
                return new AssignmentStateAwaitingQA(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.Completed) == 0)
            {
                return new AssignmentStateCompleted(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.Created) == 0)
            {
                return new AssignmentStateCreated(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.DataEntryInProgress) == 0)
            {
                return new AssignmentStateDataEntryInProgress(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.QAInProgress) == 0)
            {
                return new AssignmentStateQAInProgress(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.QAApproved) == 0)
            {
                return new AssignmentStateQAApproved(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.QAFailed) == 0)
            {
                return new AssignmentStateQAFailed(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.QAOnHold) == 0)
            {
                return new AssignmentStateQAOnHold(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.Released) == 0)
            {
                return new AssignmentStateReleased(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.Transferred) == 0)
            {
                return new AssignmentStateTransferred(throwIfInvalid);
            }
            else if (visitStatusTypeGuid.CompareTo(AssignmentStatusTypeList.ReadyForTransfer) == 0)
            {
                return new AssignmentStateReadyForTransfer(throwIfInvalid);
            }

            throw new AssignmentStateUnrecognisedStateException();

        }
    }
}
